#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<sys/types.h>

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        int count = 10;
        while(count--)
        {
            printf("I am child...PID:%d, PPID:%d\n",getpid(),getppid());
            sleep(1);
        }
        exit(0);
    }
    int status = 0;
    pid_t ret = wait(&status);
    if(ret > 0)
    {
        printf("wait child wuccess...\n");
        if(WIFEXITED(status))
        {
            printf("exit code:%d\n",WEXITSTATUS(status));
        }
    }
    sleep(3);
    return 0;
}
